﻿#region License
/*

	Copyright (C) 2008 Oliver Charles, Daniel Hollander

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
	
*/
#endregion

using System;
using System.Drawing;
using Moebius.Core;
using Tao.Sdl;

namespace Moebius.Input
{
    /// <summary>
    /// Represents a physical hardware device that handles user input.
    /// </summary>
    public sealed class InputHandler
    {
		private Point mouseLocation;
        private ILogger logger;

        #region Properties

        /// <summary>
        /// Gets the location of the mouse, relative to the window that this InputHandler is bound to
        /// </summary>
        public Point MouseLocation
        {
			get { return mouseLocation; }
        }

        public ILogger Logger
        {
            get { return logger; }
            set { logger = value; }
        }

        #endregion
        #region Events

        public event EventHandler<EventArgs> MouseClicked;

        #endregion

		#region Handle Event
		
		public void HandleEvent(Sdl.SDL_Event sdlEvent)
		{
			switch(sdlEvent.type)
			{
				case Sdl.SDL_MOUSEMOTION:
					mouseLocation = new Point(sdlEvent.motion.x, sdlEvent.motion.y);
					break;
					
				case Sdl.SDL_MOUSEBUTTONDOWN:
					if(MouseClicked != null)
						MouseClicked(this, null);

					break;
			}
		}
		
		#endregion
    }
}